/**
 * @param array - the array to search in
 * @param lenth - the number of elements in the array
 * @param element - the element to search in the array
 * @param compare - the function that compares between two elements
 */
int find(ArrayElement array, int length, Element element,
		CompareFunction compare){

	int high = (length - 1);
	int low,mid = 0;
	while (low <= high){
		mid = (low + high)/2;
		if (compare(array[mid], element) == 0) {
			return mid;
		} else if (compare(array[mid], element) < 0) {
			low = mid + 1;
		} else {
			high = mid - 1;
		}
	}
	return -1;
}
